package com.fenghongzhang.mvp_lib.view;

import android.os.Bundle;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.fenghongzhang.mvp_lib.presenter.IPresenter;

import javax.inject.Inject;


public abstract class BaseActivity<P extends IPresenter> extends AppCompatActivity implements IActivity, IView{


    @Inject
    protected P presenter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(bindLayout());
        initView();
        initDate();
    }

    @Override
    public void showToast(String s) {
        Toast.makeText(this, s, Toast.LENGTH_SHORT).show();
    }

    //2 viewceng
    @Override
    public void onDestroy() {
        super.onDestroy();
        if(presenter != null){
            presenter.destroy();
            presenter = null;
        }
    }
}
